package dbmanager.struct.conTypes;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import dbmanager.struct.DBConnectionType;

public class MysqlCon extends DBConnectionType {

	public MysqlCon() {
		setName("MySql");
		setDriverName("com.mysql.jdbc.Driver");
	}

	@Override
	public boolean connect() {

		try {
			Class.forName("com.mysql.jdbc.Driver");
			Connection newCon = DriverManager.getConnection("jdbc:mysql://" + getTargetUrl() + ":" + getPort() + "/" + getStartDatabase() + "?" + "user=" + getUserName() + "&" + "password=" + getPwd());
			setConnection(newCon);
		} catch (SQLException | ClassNotFoundException e) {
			return false;
		}

		return true;
	}

}
